@extends("d.layout.index")
@section("con")
<div class="mws-panel grid_8">
	<div class="mws-panel-header">
    	<span>推荐版块添加</span>
    </div>
    <div class="mws-panel-body no-padding">
    	<form class="mws-form" action="/admin/recommend/update" method="post" enctype="multipart/form-data">
    	{{csrf_field()}}
            <input type="hidden" name="opic" value="{{$v['pic']}}">
            <input type="hidden" name="id" value="{{$v['id']}}">
    		<div class="mws-form-inline">
    			<div class="mws-form-row">
    				<label class="mws-form-label">名称</label>
    				<div class="mws-form-item">
    					<input name="name" class="small" type="text" value="{{$v['name']}}">
    				</div>
    			</div>
                <div class="mws-form-row">
                    <label class="mws-form-label">序号</label>
                    <div class="mws-form-item">
                        <input name="order" class="small" type="text" value="{{$v['order']}}">
                    </div>
                </div>
                <div class="mws-form-row">
                    <label class="mws-form-label">描述</label>
                    <div class="mws-form-item">
                        <textarea rows="" name="des" cols="" class="small">{{$v["des"]}}</textarea>
                    </div>
                </div>
    			<div class="mws-form-row">
    				<label class="mws-form-label">图片</label>
    				<div class="mws-form-item">
    					<input name="pic" type="file" onchange="getImg(this)">
    					<span id="sp">（建议尺寸：256×150）</span>
    				</div>
    			</div>
                <div id="d"><img src="{{$path.$v['pic']}}" alt=""></div>
    			<div class="mws-form-row">
    				<label class="mws-form-label">是否在主页显示</label>
    				<div class="mws-form-item clearfix">
    					<ul class="mws-form-list inline">
    						<li><input type="radio" name="status" value="1" @if($v['status'] == 1) checked @endif> <label>是</label></li>
    						<li><input type="radio" name="status" value="0" @if($v['status'] == 0) checked @endif> <label>否</label></li>
    					</ul>
    				</div>
    			</div>
                <div class="mws-form-row">
                    <label class="mws-form-label">倒计时</label>
                    <div class="mws-form-item clearfix">
                        <ul class="mws-form-list inline">
                            <li><input type="text" name="d" value="{{floor($v['time']/(60*60*24))}}"> <label>天</label></li>
                            <li><input type="text" name="h" value="{{floor($v['time']%(60*60*24)/(60*60))}}"> <label>时</label></li>
                            <li><input type="text" name="i" value="{{floor($v['time']%(60*60)/60)}}"> <label>分</label></li>
                            <li><input type="text" name="s" value="{{$v['time']%60}}"> <label>秒</label></li>
                        </ul>
                    </div>
                </div>
                <div class="mws-form-row">
                    <label class="mws-form-label">开始时间</label>
                    <div class="mws-form-item">
                      <p class="datep">
                        <input class="datainp" name="stime" id="datebut" type="text" placeholder="请选择"  value="{{$v['stime']}}" readonly>
                        <input class="btn btn-paimary" type="button" onClick="jeDate({dateCell:'#datebut',isTime:true,format:'YYYY-MM-DD hh:mm:ss'})" value="设置">
                      </p>
                    </div>
                </div>
	    		<div class="mws-button-row">
	    			<input value="提交" class="btn btn-danger" type="submit">
	    			<input value="重置" class="btn " type="reset">
	    		</div>
	    	</div>
    	</form>
    	<script type="text/javascript">
    	function getImg(file){
			  var prevDiv = document.getElementById('d');
                if (file.files && file.files[0])  
                {  
                    var reader = new FileReader(); 
                    reader.onload = function(evt){  
                        prevDiv.innerHTML = '<img src="' + evt.target.result + '" />';  
                    }    
                    reader.readAsDataURL(file.files[0]);  
                }else{  
                    prevDiv.innerHTML = '<div class="img" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale,src=\'' + file.value + '\'"></div>';  
                }  
		}
    	</script>
    </div>    	
</div>
@endsection